#ifndef THREADSTREAM_H
#define THREADSTREAM_H

#include <QDebug>
#include <QThread>
#include <QLabel>
#include <QSize>
#include <QString>
#include <QAudioRecorder>
#include <QAudioDecoder>
#include <QStringList>
#include <QMediaPlayer>
#include <QUrl>

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

#include "DctCompression.h"
#include "RGBtoYUV.h"
#include "RleManager.h"

typedef cv::Mat MyArray;

class ThreadStream : public QThread
{
    Q_OBJECT
public:
    explicit ThreadStream(QLabel *lbl, QObject *parent = 0);
    void Pause();
    void StopPause();
    bool isPlaying();
    void StartRecording();
    void StopRecording();
    void setImgSize(QSize &size);
    bool PlayVideo(QString filename);
    bool PlayCamera();
    bool Abort();


private:
    cv::VideoCapture *source;
    void run();
    QLabel *labelImg;
    bool pause;
    bool release;
    bool record;
    bool playMyvideo;
    bool SourceCam;
    QSize _size;
    FILE *file;
    FILE *readOnly;
    QImage putImage(const cv::Mat& mat);
    RGBtoYUV    *RGB2YUV;
    DctCompression *dctCompress;
    QAudioRecorder *audioRecorder;
    QMediaPlayer *player;
    void PlayMyvideo();

signals:
    void sigSendFrame(const MyArray &fram);

public slots:
};

#endif // THREADSTREAM_H
